import { _decorator, Component, Node, Sprite } from 'cc';
import { BaseTs } from './BaseTs';
import { UiUtil } from '../../Framework/Utils/UiUtil';
import { EventUtil } from '../../Framework/Utils/EventUtil';
import { EventConstant } from '../../Framework/Constants/EventConstant';
import { HttpUtil } from '../../Framework/Utils/HttpUtil';
const { ccclass, property } = _decorator;

@ccclass('LoginViewTs')
export class LoginViewTs extends BaseTs {

    protected onLoad(): void {

        var salf = this

        var wxBtn = this.node.getChildByPath('LoginBtnView/微信登录').getComponent(Sprite);
        wxBtn.node.on(Node.EventType.TOUCH_START, function (event) {
            console.log("TOUCH_START this.coco", event.type);
            UiUtil.INSTANCE.showToast({ msg: '登录成功', millisecond: 500 })

            // 添加一个事件监听
            EventUtil.INSTANCE.addEventListen(EventConstant.WX_LOGIN_CALLBACK_EVENT, salf.wxLoginCallback, salf)

            HttpUtil.INSTANCE.post('https://work.xcnhsh.com/backend/page/index' , '我要吃饭啊' , null);
        });
    }

    public init(data: any) { }

    public wxLoginCallback(vCode: string) {
        UiUtil.INSTANCE.showToast({msg: vCode , millisecond: 2000})
    }
}

